﻿<%@ Page Language="C#" MasterPageFile="~/default.Master" AutoEventWireup="true" CodeBehind="SearchBook.aspx.cs"
    Inherits="BookNet.WebForm2" Title="Search by title" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="server">
    <br />
    <br />
    <h3>
        Search Result</h3>
    <br />
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:booknetConnectionString1 %>"
        OnSelecting="SqlDataSource3_Selecting" SelectCommand="SELECT [BookID], [Seller], [Title], [Description], [Price], [TimeAdded], [CoverImageUrl], [ForLending], [Condition], [ISBN], [Author] FROM [app_Books] WHERE (([Author] LIKE '%' + @Author + '%') OR ([Description] LIKE '%' + @Description + '%') OR ([Title] LIKE '%' + @Title + '%'))">
        <SelectParameters>
            <asp:QueryStringParameter Name="Author" QueryStringField="keyword" Type="String" />
            <asp:QueryStringParameter Name="Description" QueryStringField="keyword" Type="String" />
            <asp:QueryStringParameter Name="Title" QueryStringField="keyword" Type="String" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:ListView ID="ListView1" runat="server" DataKeyNames="BookID" DataSourceID="SqlDataSource3">
        <ItemTemplate>
            <table width="700">
                <tr>
                    <td style="width: 115px; vertical-align: top;">
                        <a href="BookDetail.aspx?id=<%# Eval("BookID") %>">
                            <asp:Image ID="Image1" runat="server" AlternateText='<%# Eval("Title") %>' ImageUrl='<%# ChooseImage(Eval("CoverImageUrl").ToString()) %>' /></a>
                    </td>
                    <td style="width: 585px;">
                        Title: <a href="BookDetail.aspx?id=<%# Eval("BookID") %>">
                            <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>'></asp:Label></a>
                        <br />
                        Seller: <a href="UserDetail.aspx?id=<%# Eval("Seller") %>">
                            <asp:Label ID="Seller" runat="server" Text='Seller'></asp:Label></a>
                        <br />
                        Description:
                        <asp:Label ID="DescriptionLabel" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                        <br />
                        Price:
                        <asp:Label ID="PriceLabel" runat="server" Text='<%# Eval("Price") %>'></asp:Label>
                        <br />
                        Time Added:
                        <asp:Label ID="TimeAddedLabel" runat="server" Text='<%# Eval("TimeAdded") %>'></asp:Label>
                        <br />
                        <asp:CheckBox ID="ForLendingCheckBox" runat="server" Checked='<%# Eval("ForLending") %>'
                            Enabled="False" Text="For Lending" />
                        <br />
                        Condition:
                        <asp:Label ID="ConditionLabel" runat="server" Text='<%# Eval("Condition") %>'></asp:Label>
                        <br />
                        ISBN:
                        <asp:Label ID="ISBNLabel" runat="server" Text='<%# Eval("ISBN") %>'></asp:Label>
                        <br />
                    </td>
                </tr>
            </table>
        </ItemTemplate>
        <AlternatingItemTemplate>
            <table width="700" style="background-color: #CCFFCC;">
                <tr>
                    <td style="width: 115px; vertical-align: top;">
                        <a href="BookDetail.aspx?id=<%# Eval("BookID") %>">
                            <asp:Image ID="Image2" runat="server" AlternateText='<%# Eval("Title") %>' ImageUrl='<%# ChooseImage(Eval("CoverImageUrl").ToString()) %>' /></a>
                    </td>
                    <td style="width: 585px;">
                        Title: <a href="BookDetail.aspx?id=<%# Eval("BookID") %>">
                            <asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>'></asp:Label></a>
                        <br />
                        Seller: <a href="UserDetail.aspx?id=<%# Eval("Seller") %>">
                            <asp:Label ID="Seller" runat="server" Text='Seller'></asp:Label></a>
                        <br />
                        Description:
                        <asp:Label ID="DescriptionLabel0" runat="server" Text='<%# Eval("Description") %>'></asp:Label>
                        <br />
                        Price:
                        <asp:Label ID="PriceLabel0" runat="server" Text='<%# Eval("Price") %>'></asp:Label>
                        <br />
                        Time Added:
                        <asp:Label ID="TimeAddedLabel0" runat="server" Text='<%# Eval("TimeAdded") %>'></asp:Label>
                        <br />
                        <asp:CheckBox ID="ForLendingCheckBox0" runat="server" Checked='<%# Eval("ForLending") %>'
                            Enabled="False" Text="ForLending" />
                        <br />
                        Condition:
                        <asp:Label ID="ConditionLabel0" runat="server" Text='<%# Eval("Condition") %>'></asp:Label>
                        <br />
                        ISBN:
                        <asp:Label ID="ISBNLabel0" runat="server" Text='<%# Eval("ISBN") %>'></asp:Label>
                        <br />
                    </td>
                </tr>
            </table>
        </AlternatingItemTemplate>
        <EmptyDataTemplate>
            No data was returned.
        </EmptyDataTemplate>
        <LayoutTemplate>
            <div style="text-align: left; background-color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif;
                color: #000000; width: 700px; padding-left: 0px;">
                <table id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif;
                    list-style-type: none; width: 600px; padding-left: 0px;">
                    <tr style="background-color: #000000; color: #000000; list-style-type: none; padding-left: 0px;">
                        <td id="itemPlaceholder" runat="server">
                        </td>
                    </tr>
                </table>
            </div>
            <div style="text-align: left; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif;
                color: #000000; width: 700px;">
                <asp:DataPager ID="DataPager1" runat="server" PageSize="5">
                    <Fields>
                        <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True" ShowLastPageButton="True" />
                    </Fields>
                </asp:DataPager>
            </div>
        </LayoutTemplate>
        <ItemSeparatorTemplate>
        </ItemSeparatorTemplate>
    </asp:ListView>
    <br />
</asp:Content>
